<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="icon" href="https://static.nowcoder.com/images/logo_87_87.png"/>
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" crossorigin="anonymous">
	<link rel="stylesheet" th:href="@{/css/global.css}" />
	<link rel="stylesheet" th:href="@{/css/typo.css}" />
	<link rel="stylesheet" th:href="@{/css/discuss-detail.css}" />
	<link rel="stylesheet" th:href="@{/lib/prism/prism.css}" />
	<link rel="stylesheet" th:href="@{/lib/tocbot/tocbot.css}" />

	<title>帖子详情</title>
</head>
<body>
	<div class="nk-container">
		<!-- 头部 -->
		<header class="bg-dark sticky-top" th:replace="index::header">
		</header>

		<!-- 内容 -->
		<div class="main">
			<!-- 帖子详情 -->
			<div class="container">
				<h5 style="text-align: center;font-weight: lighter" th:if="${postVo==null}">帖子不见啦~</h5>
				<img th:if="${postVo==null}" th:src="@{/img/nothing.png}" style="padding-left: 270px;padding-top: 50px;padding-bottom: 50px">
				<!-- 标题 -->
				<h6 class="mb-4" th:if="${postVo!=null}">
					<img class="up" th:src="@{/img/title.png}"/>
					<span class="font-size-18" style="padding-left: 10px;font-weight: bold" th:utext="${postVo.post.title}"></span>
					<div class="float-right" th:if="${loginUser!=null}">
						<img th:src="@{/img/share.png}" onclick="share()" width="24px" height="24px">
						<button th:if="${loginUser.type==1}" type="button" th:onclick="|stick(this,${postVo.post.id})|" th:class="|btn btn-sm ${postVo.post.type==1?'btn-secondary':'btn-danger'}|" th:text="${postVo.post.type==1?'取消置顶':'置顶'}">置顶</button>
						<button th:if="${loginUser.type==1}" type="button" th:onclick="|quintessence(this,${postVo.post.id})|" th:class="|btn btn-sm ${postVo.post.status==1?'btn-secondary':'btn-danger'}|" th:text="${postVo.post.status==1?'取消精华':'加精'}">加精</button>
						<a th:if="${loginUser.id==postVo.post.userId}" th:href="@{|/discuss/toUpdate/${postVo.post.id}|}"  class="btn btn-info btn-sm">修改</a>
						<button th:if="${loginUser.type==1||loginUser.id==postVo.post.userId}" th:onclick="|deleteDiscuss(${postVo.post.id})|" type="button" class="btn btn-danger btn-sm">删除</button>
					</div>
				</h6>
				<!-- 作者 -->
				<div class="media pb-3 border-bottom" th:if="${postVo!=null}">
					<a th:href="@{|/user/profile/${postVo.user.id}|}">
						<img th:src="${postVo.user.headerUrl}" class="align-self-start mr-4 rounded-circle user-header" alt="用户头像" >
					</a>
					<div class="media-body font-size-16">
						<div class="mt-0 text-warning font-size-18" th:utext="${postVo.user.username}"></div>
						<div class="text-muted mt-3">
							发布于 <b class="font-size-14" style="font-weight: inherit" th:text="${#dates.format(postVo.post.createTime,'yyyy-MM-dd HH:mm:ss')}">2019-04-15 15:32:18</b>
							<ul class="d-inline float-right">
								<li class="d-inline ml-2">
									<a href="javascript:;" style="text-decoration: none" th:onclick="|like(this,1,${postVo.post.id},${postVo.user.id});|" class="text-primary">
									<img th:src="@{${postVo.userStatus==0?'/img/like.png':'/img/like-black.png'}}" width="18px" height="20px" class="up">
									<i th:text="${postVo.likeCount}"></i>
									</a>
								</li>
								<li class="d-inline ml-2">|</li>
								<li class="d-inline ml-2"><a href="#replyform" class="text-primary"><img th:src="@{/img/comment2.png}" width="20px" height="20px">回复([[${postVo.post.commentCount}]])</a></li>
							</ul>
						</div>
					</div>
				</div>
				<!--提示框-->
				<div class="modal fade" id="hintModal" tabindex="-1" role="dialog" aria-labelledby="hintModalLabel"
					 aria-hidden="true">
					<div class="modal-dialog modal-lg" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<h5 class="modal-title" style="font-weight: lighter" id="hintModalLabel">提示</h5>
							</div>
							<div class="modal-body align-self-center" style="font-weight: lighter" id="hintBody">
								正在为您生成长图，请稍等~
							</div>
						</div>
					</div>
				</div>
				<!-- 正文 -->
				<div class="mt-4 mb-3 content js-toc-content" th:utext="${postVo.post.content}" th:if="${postVo!=null}">

				</div>
			</div>
			<!-- 回帖 -->
			<div class="container mt-3 text-muted" th:if="${postVo!=null}">
				<!-- 回帖数量 -->
				<div class="row">
					<div class="col-8">
						<h6><b class="square"></b> <i th:text="${postVo.post.commentCount}">30</i>条回帖</h6>
					</div>
				</div>
				<!-- 回帖列表 -->
				<div class="font-size-14" style="text-align: center" th:if="${comments.size()==0}">暂无回复，快来发表你的观点吧</div>
				<ul class="list-unstyled mt-4">
					<!-- 第1条回帖 -->
					<li class="media pb-3 pt-3 mb-3" th:each="commentMap:${comments}">
						<a th:href="@{|/user/profile/${commentMap.user.id}|}">
							<img th:src="${commentMap.user.headerUrl}" class="align-self-start mr-4 rounded-circle user-header" alt="用户头像" >
						</a>
						<div class="media-body font-size-14">
							<div class="mt-0">
								<span class="text-success" th:utext="${commentMap.user.username}"></span>
								<span class="badge badge-secondary float-right floor">[[${page.offset+commentMapStat.count}]]#</span>
							</div>
							<div class="mt-2" th:utext="${commentMap.comment.content}">
							</div>
							<div class="mt-4 text-muted font-size-12">
								<span>发布于 <b class="text-muted" style="font-weight: inherit" th:text="${#dates.format(commentMap.comment.createTime,'yyyy-MM-dd HH:mm:ss')}">2019-04-15 15:32:18</b></span>
								<ul class="d-inline float-right big-up">
									<li class="d-inline ml-2">
										<a href="javascript:;" style="text-decoration: none" th:onclick="|like(this,2,${commentMap.comment.id},${commentMap.user.id});|" class="text-primary">
											<img th:src="@{${commentMap.userStatus==0?'/img/like.png':'/img/like-black.png'}}" width="18px" height="20px" class="up">
											(<i th:text="${commentMap.likeCount}"></i>)
										</a>
									</li>
									<li class="d-inline ml-2">|</li>
									<li class="d-inline ml-2"><a th:href="|#pinglun-${commentMapStat.count}|" class="text-primary" data-toggle="collapse">回复([[${commentMap.replyCount}]])</a></li>
								</ul>
							</div>
							<!-- 回复列表 -->
							<ul th:id="|pinglun-${commentMapStat.count}|" class="list-unstyled mt-4 bg-gray p-3 font-size-12 text-muted collapse" style="border-radius: 10px">
								<!-- 第1条回复 -->
								<li class="pb-3 pt-3 mb-3 border-bottom" th:each="replyMap:${commentMap.replys}">
									<div>
										<span><b class="text-info" style="font-weight: inherit" th:utext="${replyMap.replyUser.username}"></b>
											<span th:if="${replyMap.target!=null}">
												回复<b class="text-info" th:utext="${replyMap.target.username}"></b>
											</span>:&nbsp;&nbsp;
										</span>
										<span th:utext="${replyMap.reply.content}"></span>
									</div>
									<div class="mt-3">
										<span class="text-muted" th:text="${#dates.format(replyMap.reply.createTime,'yyyy-MM-dd HH:mm:ss')}">2019-04-15 15:32:18</span>
										<ul class="d-inline float-right big-up">
											<li class="d-inline ml-2">
												<a href="javascript:;" style="text-decoration: none" th:onclick="|like(this,2,${replyMap.reply.id},${replyMap.replyUser.id});|" class="text-primary">
													<img th:src="@{${replyMap.userStatus==0?'/img/like.png':'/img/like-black.png'}}" width="18px" height="20px" class="up">
													(<i th:text="${replyMap.likeCount}"></i>)
												</a>
											</li>
											<li class="d-inline ml-2">|</li>
											<li class="d-inline ml-2"><a th:href="|#huifu-${replyMapStat.count}|" data-toggle="collapse" class="text-primary">回复</a></li>
										</ul>
										<div th:id="|huifu-${replyMapStat.count}|" class="mt-4 collapse">
											<form method="post" th:action="@{|/comment/addComment/${postVo.post.id}|}">
												<div>
													<input type="text" name="content" class="input-size" th:placeholder="|回复${replyMap.replyUser.username}|"/>
													<input type="hidden" name="entityType" value="2">
													<input type="hidden" name="entityId" th:value="${commentMap.comment.id}">
													<input type="hidden" name="targetId" th:value="${replyMap.replyUser.id}">
												</div>
												<div class="text-right mt-2">
													<button type="submit" class="btn btn-primary btn-sm" onclick="#">&nbsp;&nbsp;回&nbsp;&nbsp;复&nbsp;&nbsp;</button>
												</div>
											</form>
										</div>
									</div>								
								</li>
								<!-- 回复输入框 -->
								<li class="pb-3 pt-3">
									<form th:action="@{|/comment/addComment/${postVo.post.id}|}" method="post">
										<div>
											<input type="text" name="content" class="input-size" placeholder="请输入你的观点"/>
											<input type="hidden" name="entityType" value="2">
											<input type="hidden" name="entityId" th:value="${commentMap.comment.id}">
										</div>
										<div class="text-right mt-2">
											<button type="submit" class="btn btn-primary btn-sm" onclick="#">&nbsp;&nbsp;回&nbsp;&nbsp;复&nbsp;&nbsp;</button>
										</div>
									</form>
								</li>
							</ul>
						</div>
					</li>
				</ul>
				<!-- 分页 -->
				<nav class="mt-5" th:replace="index::page">
				</nav>			
			</div>
			<!-- 回帖输入 -->
			<div class="container mt-3 font-size-14" th:if="${postVo!=null}">
				<form class="replyform" th:action="@{|/comment/addComment/${postVo.post.id}|}" method="post">
					<p class="mt-3">
						<a name="replyform"></a>
						<textarea class="text-muted" name="content" placeholder="在这里畅所欲言你的看法吧!" style="padding:10px 15px;border-radius: 10px"></textarea>
						<input type="hidden" name="entityType" value="1">
						<input type="hidden" name="entityId" th:value="${postVo.post.id}">
					</p>
					<p class="text-right">
						<button type="submit" class="btn btn-primary btn-sm">&nbsp;&nbsp;回&nbsp;&nbsp;帖&nbsp;&nbsp;</button>
					</p>
				</form>
			</div>
		</div>
		<!--目录-->
		<div class="mybox m-fixed m-right-top font-size-14">
			<span class="text-muted" style="padding-left: 10px">目录</span>
			<ol id="catalogue" class="js-toc">
			</ol>
		</div>
		<!--回到顶部-->
		<img onclick="$(window).scrollTo(0,500)" class="m-fixed m-right-bottom" th:src="@{/img/backtop.png}">
		<!-- 尾部 -->
		<footer class="bg-dark" th:replace="index::footer">
		</footer>
	</div>
	<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" crossorigin="anonymous"></script>
	<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" crossorigin="anonymous"></script>
	<!--平滑滚动-->
	<script src="https://cdn.jsdelivr.net/npm/jquery.scrollto@2.1.3/jquery.scrollTo.min.js"></script>
	<script th:src="@{/js/global.js}"></script>
	<script th:src="@{/lib/prism/prism.js}"></script>
	<script th:src="@{/lib/tocbot/tocbot.min.js}"></script>
	<script th:src="@{/js/discuss.js}"></script>
</body>
</html>
